SELECT COUNT(1)
FROM FD_SITE T
WHERE 1 = 1
<#if (CODE!) != ''>
  AND (INSTR (T.CODE, :CODE )> 0
  OR INSTR (T.NAME, :CODE )    > 0)
</#if>
<#if (DOMAIN_NA_CODE!) != ''>
  AND EXISTS
    (SELECT 1
    FROM FD_DOMAIN_NA EDN
    WHERE EDN.SITE_ID                      = T.ID
    AND (INSTR (EDN.CODE, :DOMAIN_NA_CODE )> 0
    OR INSTR (EDN.NAME, :DOMAIN_NA_CODE )  > 0)
    )
</#if>